package com.supermap.business.deviceInfo;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.deviceinfo.StationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author:langhongshuai
 * @Description:站点信息接口层（内蒙数据库）
 * @Date:18/5/14 下午5:25
 */
@Controller
@RequestMapping("StationController")
public class StationController {
    /**
     * 使用指定类初始化日志对象，在日志输出的时候，可以打印出日志信息所在类
     */
    protected static final Logger logger = LoggerFactory.getLogger(DeviceInfoController.class);

    @Reference
    private StationService stationService;

    /**
     * 通过deviceid和date获得用户的站点信息
     */
    @RequestMapping("/getStationByDeviceIdAndDate")
    @ResponseBody
    public JSONUtil getStationByDeviceIdAndDate(HttpServletRequest request, HttpServletResponse response) {
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST,GET,OPTIONS,DELETE");
        response.setHeader("Access-Control-Max-Age", "1800");
        String date = request.getParameter("date");
        String deviceId= request.getParameter("deviceId");
        return stationService.getStationByDeviceIdAndDate(deviceId,date);
    }
}
